import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)


const getMappedRoutes = (r) => (
  r.map(route => ({
    ...route,
    component: (resolve) => require([`../pages/${route.page}`], resolve),
    children: route.children ? getMappedRoutes(route.children) : undefined
  }))
)

let baseRoutes = [{
  path: '/login',
  name: '登录',
  page: 'Login/Login.vue'
}, {
  path: '/404',
  name: '找不到页面',
  page: 'Login/Login.vue'
}, ]

export const router = new VueRouter({
  mode: 'hash',
  routes: getMappedRoutes(baseRoutes)
})